package com.tianhao.luo.reply.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tianhao.luo.reply.TextReplyAble;
import com.tianhao.luo.utils.HttpUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author tianhao.luo
 * @date 2020/3/12 19:41
 */
public class NormalTextReplyAbleImpl implements TextReplyAble {
    @Override
    public String textReply(String condition) {
        if (condition.contains("时间") || condition.contains("time")) {
            Date date = new Date();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return "愿你每一天都有好心情。当前时间是："+dateFormat.format(date);
        }else if (condition.matches("[1-9][0-9]*\\+[1-9][0-9]*")){
            String[] split = condition.split("\\+");
            int i = Integer.parseInt(split[0]) + Integer.parseInt(split[1]);
            return condition+"结果是"+String.valueOf(i);
        }else if (condition.matches("[1-9][0-9]*\\*[1-9][0-9]*")){
            String[] split = condition.split("\\*");
            int i = Integer.parseInt(split[0]) * Integer.parseInt(split[1]);
            return condition+"结果是"+String.valueOf(i);
        }else if (condition.matches("[1-9][0-9]*-[1-9][0-9]*")){
            String[] split = condition.split("-");
            int i = Integer.parseInt(split[0]) - Integer.parseInt(split[1]);
            return condition+"结果是"+String.valueOf(i);
        }
        else {
            return "抱歉我分析不出来了";
        }
    }
}
